using UnityEngine;
namespace ScreenAdapter
{
    /// <summary>
    /// anchorPositon 和 scale 适配器
    /// </summary>
    public class ScaleAdapter : AspectRatioAdapterUGUI
    {
        [System.Serializable]
        public new class Config : AspectRatioAdapter.Config
        {
            public Vector3 scale;
        }

        public  Config[] configs;

        public override AspectRatioAdapter.Config[] Configs
        {
            get { return configs; }

            set
            {
                configs = new Config[value.Length];
                for (int i = 0; i < value.Length; i++)
                {
                    configs[i] = value[i] as Config;
                }
                Debug.Log("AnchorPosiAdapter 适配数据更新");
            }
        }

        protected override void OnConfigUsed(AspectRatioAdapter.Config config)
        {
            var myConfig = config as Config;
            screenRect.localScale = myConfig.scale;
        }
        public override AspectRatioAdapter.Config CreateConfig()
        {
            return new Config();
        }
        protected override void OnSaveCurrentStatus(AspectRatioAdapter.Config config)
        {
            var myConfig = config as Config;
            myConfig.scale = screenRect.localScale;
        }
    }
}
